home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2003 November / PCWK1103B.iso / DesignCAD 3D Max PLUS trial 30 / DATA1.CAB / Example_Files / Sample_Macros / 4PtCopy.d3m < prev    next >
Encoding:
Text File  |  2003-09-29  |  2.1 KB  |  121 lines

  1. 'Sys(800) = 1          ' +++++++ Turn on Tracing Dialog
  2.  
  3. nSelEntity = sys(80)
  4.  
  5. if nSelEntity < 1 then
  6.   Message "Please select objects before running this program"
  7.   end
  8.   endif
  9.  
  10. SETPOINT "Set points: 1-Lower Left, 2-Lower Right, 3-Upper Left, 4-Upper Right", 4
  11. if sys(1) < 4 then
  12.   Message "Four points are needed to complete the command."
  13.   end
  14.   endif
  15.  
  16. POINTVAL Qx, Qy, Qz, 3
  17. POINTVAL Rx, Ry, Rz, 4
  18. POINTVAL Sx, Sy, Sz, 2
  19. POINTVAL Tx, Ty, Tz, 1
  20.  
  21. sys(36) = 1
  22.  
  23. xh = sys(190)
  24. yh = sys(191)
  25. zh = sys(202)
  26. >Duplicate
  27. {
  28.   <PointXYZ [xh, yh, zh]
  29.   }
  30.  
  31. >VectorConvert
  32. {
  33.   }
  34.  
  35. minX = sys(196)
  36. minY = sys(197)
  37. maxX = sys(198)
  38. maxY = sys(199)
  39.  
  40. Ax = minX
  41. Ay = maxY
  42.  
  43. Bx = maxX
  44. By = maxY
  45.  
  46. Cx = maxX
  47. Cy = minY
  48.  
  49. Dx = minX
  50. Dy = minY
  51.  
  52. dim x(400), y(400), z(400)
  53.  
  54. nSelEntity = sys(80)
  55.  
  56. for i = 1 to nSelEntity
  57.   GetSelect i, k
  58.   Entity k
  59.  
  60.   if sys(90) = 1 then
  61.     npts = sys(99)
  62.     for j = 1 to npts
  63.       PointVal x(j), y(j), z(j), j
  64.       ratio1 = (x(j) - Dx) / (Cx - Dx)
  65.       ratio2 = (y(j) - Dy) / (Ay - Dy)
  66.  
  67.       pTSx = Tx + ratio1*(Sx-Tx)
  68.       pTSy = Ty + ratio1*(Sy-Ty)
  69.       pTSz = Tz + ratio1*(Sz-Tz)
  70.  
  71.       pQRx = Qx + ratio1*(Rx-Qx)
  72.       pQRy = Qy + ratio1*(Ry-Qy)
  73.       pQRz = Qz + ratio1*(Rz-Qz)
  74.  
  75.       pTQx = Tx +ratio2*(Qx-Tx)
  76.       pTQy = Ty +ratio2*(Qy-Ty)
  77.       pTQz = Tz +ratio2*(Qz-Tz)
  78.  
  79.       pSRx = Sx + ratio2*(Rx-Sx)
  80.       pSRy = Sy + ratio2*(Ry-Sy)
  81.       pSRz = Sz + ratio2*(Rz-Sz)
  82.  
  83.       b = ((pSRy-pTQy)*(pTQx-pTSx)-(pSRx-pTQx)*(pTQy-pTSy))/((pSRy-pTQy)*(pQRx-pTSx)-(pSRx-pTQx)*(pQRy-pTSy))
  84.  
  85.       x(j) = pTSx + b*(pQRx-pTSx)
  86.       y(j) = pTSy + b*(pQRy-pTSy)
  87.       z(j) = pTSz + b*(pQRz-pTSz)
  88.       next
  89.  
  90.       ir = sys(290)
  91.       ig = sys(291)
  92.       ib = sys(292)
  93.       lay = sys(93)
  94.       ltype = sys(91)
  95.       dscale = sys(97)
  96.       bold = sys(98)
  97.  
  98.       >Line
  99.       {
  100.         <Color [ir, ig, ib]
  101.         <Layer [lay]
  102.         <LineStyle [ltype, dscale, bold]
  103.  
  104.         for j = 1 to npts
  105.           <PointXYZ [x(j), y(j), z(j)]
  106.           next
  107.         }
  108.     endif
  109.  
  110.   next
  111.  
  112. >SelectDelete
  113. {
  114.   }
  115.  
  116. >Regenerate
  117. {
  118.   }
  119.  
  120. sys(36) = 0
  121.